package org.unicamp.gesture;

import java.io.File;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;

public class SignatureCheckActivity extends Activity {
	private Button draw;
	private Button cancel;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		if (!verificaAssinatura()) {
			AlertDialog alert = new AlertDialog.Builder(this).create();
			alert.setTitle("Assinatura Pendente");
			alert.setMessage("Não foi inserida nenhuma assinatura para checar");
			alert.setButton("OK", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					Intent intent = new Intent(SignatureCheckActivity.this,
							MainActivity.class);
					startActivityForResult(intent, 0);
				}
			});
			alert.show();
		}
		
		this.setContentView(R.layout.check);
		
		draw = (Button) findViewById(R.id.button1);
		draw.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), DrawCheckActivity.class);
				startActivityForResult(intent, 0);
			}
		});
		
		cancel = (Button) findViewById(R.id.button2);
		cancel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), MainActivity.class);
				startActivityForResult(intent, 0);
			}
		});

	}

	private boolean verificaAssinatura() {
		String path = Environment.getExternalStorageDirectory().toString();
		path = path + "/gsapp/";
		File folder = new File(path);
		File imageFile = new File(folder, "0.png");
		return imageFile.exists();
	}
}
